package com.ruoyi.management.basics.controller;

import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.domain.entity.SysDept;
import com.ruoyi.common.core.domain.model.LoginUser;
import com.ruoyi.system.service.ISysDeptService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * web层通用数据处理扩展
 *
 * @author ruoyi
 */
@RestController
@RequestMapping("/base")
public class BaseExtController extends BaseController {
    @Autowired
    private ISysDeptService deptService;


    /**
     * 获取登录用户公司id
     * @return
     */
    @GetMapping("/getCompanyId")
    public Long getCompanyId()
    {
        LoginUser user = getLoginUser();
        SysDept dept = deptService.selectDeptById(user.getDeptId());
        if (null != dept && null != dept.getCompanyId())
        {
            return dept.getCompanyId();
        }
        return null;
    }

}
